package com.example.data_receiver.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

// 配置类，用于注册过滤器
@Configuration
public class WebConfig {

    @Bean
    public FilterRegistrationBean<IllegalCharacterFilter> illegalCharacterFilterRegistration() {
        FilterRegistrationBean<IllegalCharacterFilter> registration = new FilterRegistrationBean<>();
        // 创建自定义过滤器实例
        registration.setFilter(new IllegalCharacterFilter());
        // 添加过滤器要拦截的路径
        registration.addUrlPatterns("/*");
        // 设置过滤器的顺序
        registration.setOrder(1);
        return registration;
    }
}    